import { request } from "umi";

/** 获取规格模板列表 */
export async function specTemplateList({ current, pageSize, template_name }: Partial<COMMON.PageParams> & { template_name?: string }) {
  return request<COMMON.PageResult<STOCKGOODSAPI.SpecTemplate>>(`/api/inventory/template/from/${current}/limit/${pageSize}`, {
    params: { key_words: template_name }
  });
}

/** 新增规格模板 */
export async function addSpecTemplate(template_name: string, template_conent: string[]) {
  return request<STOCKGOODSAPI.SpecTemplate>(`/api/inventory/template`, {
    method: 'POST',
    data: { template_name, template_conent }
  });
}

/** 修改规格模板 */
export async function editSpecTemplate(template_id: string, template_name: string, template_conent: string[]) {
  return request<STOCKGOODSAPI.SpecTemplate>(`/api/inventory/template/${template_id}`, {
    method: 'PATCH',
    data: { template_name, template_conent }
  });
}

/** 删除规格模板 */
export async function deleteSpecTemplate(template_id: string) {
  return request(`/api/inventory/template/${template_id}`, {
    method: 'DELETE'
  });
}

/** 获取默认的模板 */
export async function getDefaultTemplate() {
  return request(`/api/inventory/default/template`, {
  });
}

